package util;

import nme.Lib;
import nme.text.TextField;
import nme.text.TextFormat;
import nme.text.TextFormatAlign;
import nme.Assets;

class ScoreBoard extends TextField {

  var _score:Int;

  // Constructor =====================================================
  public function new(XPos:Int=20, YPos:Int=20, col:Int = 0xFFFFFF, 
		      font:String = "_sans"):Void {
    super();
    selectable = false;   // El texto no se puede seleccionar
    embedFonts = true;    // La fuente se incrusta en Flash
    
    x = XPos; y = YPos;
    font = Assets.getFont (font).fontName;
    var tf:TextFormat = new TextFormat(font, 50, col, true);
    tf.align = TextFormatAlign.CENTER;
    defaultTextFormat = tf;
    _score = 0;
    update();
  }

  // update ==========================================================  
  public function update(delta:Int = 0):Void {
    _score += delta;
    htmlText = Std.string(_score);
  }
}